/*
 Copyright (c) 2013 MeherTJ G. All rights reserved.
 License: LGPL for personnal study or free software.
 */

#pragma once

#include "zen_image.h"

namespace Zen
{
	struct ImageDecoder
	{
		virtual std::shared_ptr<Image> decode(std::vector<uint8_t> const & data) = 0;
		virtual ~ImageDecoder() = default;
	};
	
	struct ImageEncoder
	{
		virtual std::vector<uint8_t> encode(Image const &) = 0;
		virtual ~ImageEncoder() = default;
	};

	/**
	 This(raw) is a simple bitmap image format.

	 definition: header(8 bytes) + data(pixel bytes in order).
	 header = sign(3B, 'jai') + format(1B) + width(2B) + height(2B). big endian order.
	 */
	struct ImageRDecoder : ImageDecoder
	{
		virtual std::shared_ptr<Image> decode(std::vector<uint8_t> const & data);
	};

	struct ImageREncoder : ImageEncoder
	{
		virtual std::vector<uint8_t> encode(Image const &) override;
	};
	
	struct ImageJPGEncoder : ImageEncoder
	{
		float quality = 1.f; // 1.0 high, 0.0:low
		virtual std::vector<uint8_t> encode(Image const &) override;
	};

	struct ImagePNGEncoder : ImageEncoder
	{
		virtual std::vector<uint8_t> encode(Image const &) override;
	};
	struct ImageTGAEncoder : ImageEncoder
	{
		virtual std::vector<uint8_t> encode(Image const &) override;
	};
	struct ImageBMPEncoder : ImageEncoder
	{
		virtual std::vector<uint8_t> encode(Image const &) override;
	};
	struct ImageDefaultDecoder : ImageDecoder
	{
		std::shared_ptr<Image> decode(const std::vector<uint8_t> &data) override;
	};
}

